package com.zzptc.myapp1127;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.zzptc.myapp1127.Service.OilPriceService;
import com.zzptc.myapp1127.Service.QichepinpaiService;
import com.zzptc.myapp1127.entity.OilPrice;
import com.zzptc.myapp1127.entity.Qichepinpai;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class Main2Activity extends AppCompatActivity {
    private static final String TAG = "Main2Activity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        getOilPriceInfo();
    }

    private void getOilPriceInfo() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://apis.juhe.cn")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        OilPriceService oilPriceService = retrofit.create(OilPriceService.class);

        Map<String, String> map = new HashMap<>();
        map.put("key", "e0106d4f036cf6d539ae0469d19545b2");
        Call<OilPrice> allOilPrice = oilPriceService.getAllOilPrice(map);

        allOilPrice.enqueue(new Callback<OilPrice>() {
            @Override
            public void onResponse(Call<OilPrice> call, Response<OilPrice> response) {
                OilPrice body = response.body();
                Log.d(TAG,"onResponse"+OilPrice.class);



            }

            @Override
            public void onFailure(Call<OilPrice> call, Throwable t) {
                Log.d(TAG,"onFailure"+t.getMessage());

            }
        });
    }

}
